package com.sdx.console.contract.backstage.Utils;

import com.itextpdf.awt.geom.Rectangle2D;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Font;
import com.itextpdf.text.Image;
import com.itextpdf.text.pdf.*;
import com.itextpdf.text.pdf.parser.ImageRenderInfo;
import com.itextpdf.text.pdf.parser.PdfReaderContentParser;
import com.itextpdf.text.pdf.parser.RenderListener;
import com.itextpdf.text.pdf.parser.TextRenderInfo;
import com.swetake.util.Qrcode;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/** 
* 数字转换为汉语中人民币的大写<br> 
* http://www.cnblogs.com/hongten/p/hongten_java_money.html 
*  
* @author hongten 
* @contact hongtenzone@foxmail.com 
* @create 2013-08-13 
*/  
public class WxInvoiceHandler {  
  /** 
   * 汉语中数字大写 
   */  
  private static final String[] CN_UPPER_NUMBER = { "零", "壹", "贰", "叁", "肆","伍", "陆", "柒", "捌", "玖" };  
  public static final String	TPLDIR	= "C:/Users/admin/Desktop/图片/"; // /opt/apache-tomcat-7.0.63/webapps/sdx/u/ C:/Users/admin/Desktop/图片/	
  public static final String	TPLDIR1	= ""; // /opt/apache-tomcat-7.0.63/webapps/sdx/u/
  //private static final String[] CN_UPPER_NUMBER = { "零", "一", "二", "三", "四","五","六", "七", "八","九" };  
  /** 
   * 汉语中货币单位大写，这样的设计类似于占位符 
   */
  private static final String[] CN_UPPER_MONETRAY_UNIT = { "分", "角", "元",  
          "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟", "兆", "拾",  
          "佰", "仟" };  
  /** 
   * 特殊字符：整 
   */  
  private static final String CN_FULL = "整";  
  /** 
   * 特殊字符：负 
   */  
  private static final String CN_NEGATIVE = "负";  
  /** 
   * 金额的精度，默认值为2 
   */  
  private static final int MONEY_PRECISION = 2;  
  /** 
   * 特殊字符：零元整 
   */  
  private static final String CN_ZEOR_FULL = "零元" + CN_FULL;  

  /** 
   * 把输入的金额转换为汉语中人民币的大写 
   *  
   * @param numberOfMoney 
   *            输入的金额 
   * @return 对应的汉语大写 
   */  
  public static String number2CNMontrayUnit(BigDecimal numberOfMoney) {  
      StringBuffer sb = new StringBuffer();  
      // -1, 0, or 1 as the value of this BigDecimal is negative, zero, or  
      // positive.  
      int signum = numberOfMoney.signum();  
      // 零元整的情况  
      if (signum == 0) {  
          return CN_ZEOR_FULL;  
      }  
      //这里会进行金额的四舍五入  
      long number = numberOfMoney.movePointRight(MONEY_PRECISION)  
              .setScale(0, 4).abs().longValue();  
      // 得到小数点后两位值  
      long scale = number % 100;  
      int numUnit = 0;  
      int numIndex = 0;  
      boolean getZero = false;  
      // 判断最后两位数，一共有四中情况：00 = 0, 01 = 1, 10, 11  
      if (!(scale > 0)) {  
          numIndex = 2;  
          number = number / 100;  
          getZero = true;  
      }  
      if ((scale > 0) && (!(scale % 10 > 0))) {  
          numIndex = 1;  
          number = number / 10;  
          getZero = true;  
      }  
      int zeroSize = 0;  
      while (true) {  
          if (number <= 0) {  
              break;  
          }  
          // 每次获取到最后一个数  
          numUnit = (int) (number % 10);  
          if (numUnit > 0) {  
              if ((numIndex == 9) && (zeroSize >= 3)) {  
                  sb.insert(0, CN_UPPER_MONETRAY_UNIT[6]);  
              }  
              if ((numIndex == 13) && (zeroSize >= 3)) {  
                  sb.insert(0, CN_UPPER_MONETRAY_UNIT[10]);  
              }  
              sb.insert(0, CN_UPPER_MONETRAY_UNIT[numIndex]);  
              sb.insert(0, CN_UPPER_NUMBER[numUnit]);  
              getZero = false;  
              zeroSize = 0;  
          } else {  
              ++zeroSize;  
              if (!(getZero)) {  
                  sb.insert(0, CN_UPPER_NUMBER[numUnit]);  
              }  
              if (numIndex == 2) {  
                  if (number > 0) {  
                      sb.insert(0, CN_UPPER_MONETRAY_UNIT[numIndex]);  
                  }  
              } else if (((numIndex - 2) % 4 == 0) && (number % 1000 > 0)) {  
                  sb.insert(0, CN_UPPER_MONETRAY_UNIT[numIndex]);  
              }  
              getZero = true;  
          }  
          // 让number每次都去掉最后一个数  
          number = number / 10;  
          ++numIndex;  
      }  
      // 如果signum == -1，则说明输入的数字为负数，就在最前面追加特殊字符：负  
      if (signum == -1) {  
          sb.insert(0, CN_NEGATIVE);  
      }  
      // 输入的数字小数点后两位为"00"的情况，则要在最后追加特殊字符：整  
      if (!(scale > 0)) {  
          sb.append(CN_FULL);  
      }  
      return sb.toString();  
  }  
  /** 生成电子合同pdf
	 * 
	 * @param
	 * @param
	 * @param
	 * @param
	 * @return
	 * @throws IOException 
	 * @throws DocumentException */

	
	public  void getPdf(String studentName,String schoolName,String className,String degree,String address,String mailCode,String phone,
			String parentName,String degree1,String address1,String mailCode1,String phone1, List<Map<Integer, Integer>> list,String wgame,String filehead ) throws IOException, DocumentException {
		Map<Integer, Integer>  zy = new HashMap<Integer,Integer>();
		Map<Integer, Integer>  jzz = new HashMap<Integer,Integer>();
		Map<Integer, Integer>  bzz = new HashMap<Integer,Integer>();
		Map<Integer, Integer>  gat = new HashMap<Integer,Integer>();
		
		for(Map<Integer, Integer> j : list){
			   
			if(j.containsKey(1)){
				jzz.put(1, j.get(1));
			}
			if(j.containsKey(2)){
				zy.put(2, j.get(2));
			}
			if(j.containsKey(3)){
				gat.put(3, j.get(3));
			}
			if(j.containsKey(4)){
				bzz.put(4, j.get(4));
			}
			} 
		
		
		
		
		 
		 //创建一个pdf读入流 
		 PdfReader reader = new PdfReader(TPLDIR+"Template.pdf");
		 
		 //根据一个pdfreader创建一个pdfStamper.用来生成新的pdf.  
		 PdfStamper stamper = new PdfStamper(reader,  new FileOutputStream(TPLDIR+TPLDIR1+filehead+".pdf"));
			
	     //这个字体是itext-asian.jar中自带的 所以不用考虑操作系统环境问题.  
		 BaseFont bfChinese = BaseFont.createFont(BaseFont.ZAPFDINGBATS, "", BaseFont.EMBEDDED);
			//BaseFont bfChinese = BaseFont.createFont(TPLDIR+"MSYH.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
				
				/*com.itextpdf.text.Font FontChinese24 = new com.itextpdf.text.Font(
						bfChinese, 24, com.itextpdf.text.Font.BOLD);
				com.itextpdf.text.Font FontChinese18 = new com.itextpdf.text.Font(
						bfChinese, 18, com.itextpdf.text.Font.BOLD);
				com.itextpdf.text.Font FontChinese16 = new com.itextpdf.text.Font(
						bfChinese, 16, com.itextpdf.text.Font.BOLD);
				com.itextpdf.text.Font FontChinese12 = new com.itextpdf.text.Font(
						bfChinese, 12, com.itextpdf.text.Font.NORMAL);
				com.itextpdf.text.Font FontChinese11Bold = new com.itextpdf.text.Font(
						bfChinese, 11, com.itextpdf.text.Font.BOLD);
				com.itextpdf.text.Font FontChinese11 = new com.itextpdf.text.Font(
						bfChinese, 11, com.itextpdf.text.Font.ITALIC);
				com.itextpdf.text.Font FontChinese11Normal = new com.itextpdf.text.Font(
						bfChinese, 11, com.itextpdf.text.Font.NORMAL);*/  
	        //baseFont不支持字体样式设定.但是font字体要求操作系统支持此字体会带来移植问题.  
	        Font font = new Font(bfChinese,10);
	        font.setStyle(Font.BOLD);
	        font.getBaseFont(); 
	        
	        List<float[]> arrays = new ArrayList<float[]>();
	        float[] p1 = {385.6f, 728.76f, 1.0f};
	        float[] p2 = {229.098f, 166.989f, 1.0f};
	        float[] p3 = {297.859f, 166.989f, 1.0f};
	        float[] p4 = {360.267f, 166.989f, 1.0f};
	        float[] p5 = {261.17047f, 660.522f, 2.0f};
	        float[] p6 = {126.7125f, 636.803f, 2.0f};
	        float[] p7 = {329.5305809f, 636.193f, 2.0f};
	        float[] p8 = {272.53754f, 92.554f, 2.0f};
	        float[] p9 = {388.5725f, 92.554f, 2.0f};
	        float[] p10 = {161.833f, 613.57f, 2.0f};
	        float[] p11 = {161.833f, 590.027f, 2.0f};
	        float[] p12 = {161.833f, 566.857f, 2.0f};
	        float[] p13 = {161.833f, 542.567f, 2.0f};
	        float[] p14 = {337.471f, 496.228f, 2.0f};
	        float[] p15 = {161.833f, 473.059f, 2.0f};
	        float[] p16 = {161.833f, 449.142f, 2.0f};
	        float[] p17 = {161.833f, 425.225f, 2.0f};
	        float[] p18 = {161.833f, 403.925f, 2.0f};
	        float[] p19 = {304.8545f, 754.59f, 3.0f};
	        float[] p20 = {398.78796f,754.59f, 3.0f};
	        float[] p21 = {306.057f, 734.495f, 3.0f};
	        float[] p22 = {400.033f, 734.755f, 3.0f};
	        float[] p23 = {306.797f, 714.516f, 3.0f};
	        float[] p24 = {400.626f, 714.721f, 3.0f};
	        float[] p25 = {199.288f, 231.81f, 6.0f};
	        float[] p26 = {408.07147f, 618.642f, 7.0f};
	        float[] p27 = {161.41649f, 584.554f, 7.0f};
	        float[] p28 = {200.07549f, 584.554f, 7.0f};
	        float[] p29 = {238.60649f, 584.554f, 7.0f};
	        float[] p30 = {389.4865f, 584.72003f, 7.0f};
	        float[] p31 = {428.02502f, 584.7197f, 7.0f};
	        float[] p32 = {461.17798f, 584.7197f, 7.0f};
	        float[] p33 = {183.81349f, 550.722f, 7.0f};
	        float[] p34 = {441.2245f, 550.722f, 7.0f};
	        
	        float[] p35 = {119.41254f, 92.5541f, 2.0f};
	        float[] p36 = {119.41254f, 754.591f, 3.0f};
	        float[] p37 = {119.41254f, 734.7551f, 3.0f};
	        float[] p38 = {119.41254f, 714.7211f, 3.0f};

	        
          arrays.add(p1);
          arrays.add(p2);
          arrays.add(p3);
          arrays.add(p4);
          arrays.add(p5);
          arrays.add(p6);
          arrays.add(p7);
          arrays.add(p8);
          arrays.add(p9);
          arrays.add(p10);
          arrays.add(p11);
          arrays.add(p12);
          arrays.add(p13);
          arrays.add(p14);
          arrays.add(p15);
          arrays.add(p16);
          arrays.add(p17);
          arrays.add(p18);
          arrays.add(p19);
          arrays.add(p20);
          arrays.add(p21);
          arrays.add(p22);
          arrays.add(p23);
          arrays.add(p24);
          arrays.add(p25);
          arrays.add(p26);
          arrays.add(p27);
          arrays.add(p28);
          arrays.add(p29);
          arrays.add(p30);
          arrays.add(p31);
          arrays.add(p32);
          arrays.add(p33);
          arrays.add(p34);
          arrays.add(p35);
          arrays.add(p36);
          arrays.add(p37);
          arrays.add(p38);
	        
	        
	        /*List<float[]> first=getKeyWords(reader,"牛"); //[352.85416, 728.33, 1.0] //385.6, 728.76, 1.0
	        System.out.println(first.toString());;*/
	        for (int i=1; i<=reader.getNumberOfPages(); i++){
	        	for(float[] school:arrays)
	        	{    
	        		
	        		if(school[2]==i){
	        			 //获得pdfstamper在当前页的上层打印内容.也就是说 这些内容会覆盖在原先的pdf内容之上.  
	    	            PdfContentByte over = stamper.getOverContent(i);
	    	          //用pdfreader获得当前页字典对象.包含了该页的一些数据.比如该页的坐标轴信息.  
	    	            PdfDictionary p = reader.getPageN(i);
	    	          //拿到mediaBox 里面放着该页pdf的大小信息.  
	    	            PdfObject po =  p.get(new PdfName("MediaBox"));
	    	            System.out.println(po.isArray());
	    	          //po是一个数组对象.里面包含了该页pdf的坐标轴范围.  
	    	            PdfArray pa = (PdfArray) po;
	    	            System.out.println(pa.size());
	    	            System.out.println(school[0]+"-"+school[1]+"页码"+school[2]);
	    	            //看看y轴的最大值.  
	    	            System.out.println(pa.getAsNumber(pa.size()-1));
	    	            //开始写入文本  
	    	            over.beginText();  
	    	            
	    	          //设置字体的输出位置  
	    	            over.setTextMatrix(school[0]-6.25f, school[1]);
	    	            
	    	          //要输出的text  
	    	            if(school[1]==728.76f){
	    	            //设置字体和大小  
		    	        over.setFontAndSize(font.getBaseFont(), 15);
		    	        //设置字体颜色
		    	        over.setColorFill(BaseColor.RED);
	    				
	    	            over.showText(filehead);    
	    	            }

	    	            if(school[0]==229.098f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 20);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
		    				
		    	            over.showText(filehead.substring(3,4));    
		    	            }
	    	            if(school[0]==297.859f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 20);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
		    				
		    	            over.showText(filehead.substring(4,6));    
		    	            }
	    	            if(school[0]==360.267f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 20);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
		    				
		    	            over.showText(filehead.substring(6,8));    
		    	            }
	    	            if(school[0]==261.17047f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 11);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
		    				
		    	            over.showText(studentName);    
		    	            }
	    	            if(school[0]==126.7125f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 8);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
		    				
		    	            over.showText(schoolName);    
		    	            }
	    	            if(school[0]==329.5305809f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 8);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
		    				
		    	            over.showText(className);    
		    	            }
	    	            if(school[1]==613.57f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 11);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
		    				if(null!=degree){
		    	            over.showText(degree);
		    	            }else{
		    	            over.showText("");	
		    	            }
		    				
		    	            }
	    	            if(school[1]==590.027f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 11);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
			    	        if(null!=address){
			    	        	 over.showText(address); 
			    	            }else{
			    	            over.showText("");}
		    	              
		    	            }
	    	            if(school[1]==566.857f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 11);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
			    	        if(null!=degree){
			    	        	over.showText(mailCode); 
			    	            }else{
			    	            over.showText("");}
		    	               
		    	            }
	    	            if(school[1]==542.567f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 11);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
		    				
		    	            over.showText(phone);    
		    	            }
	    	            
	    	            if(school[1]==496.228f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 11);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
			    	        if(null!=degree){
			    	        	over.showText(parentName);  
			    	            }else{
			    	            over.showText("");}
		    	               
		    	            }
	    	            if(school[1]==473.059f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 11);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
			    	        if(null!=degree){
			    	        	over.showText(degree1); 
			    	            }else{
			    	            over.showText("");}
		    	                
		    	            }
	    	            if(school[1]==449.142f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 11);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
			    	        if(null!=address1){
			    	        	over.showText(address1);  
			    	            }else{
			    	            over.showText("");}
		    	               
		    	            }
	    	            
	    	            
	    	            if(school[1]==425.225f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 11);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
			    	        if(null!=degree){
			    	        	over.showText(mailCode1); 
			    	            }else{
			    	            over.showText("");}
		    	                
		    	            }
	    	            
	    	            
	    	            if(school[1]==403.925f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 11);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
		    				
		    	            over.showText(phone1);    
		    	            }
	    	            
	    	               
	    	            	if(school[0]==272.53754f){
	    	            	            if(null!=zy&&zy.size()!=0){
	    			    	            //设置字体和大小  
	    				    	        over.setFontAndSize(font.getBaseFont(), 8);
	    				    	        //设置字体颜色
	    				    	        over.setColorFill(BaseColor.RED);
	    				    	        over.showText(zy.get(2).toString());
	    				    	        
	    	            	            
	    	            	            
	    	            	            }
	    	            	            else{
	    	            	            	over.setFontAndSize(font.getBaseFont(), 8);
    						    	        //设置字体颜色
    						    	        over.setColorFill(BaseColor.RED);
    			    	            	   over.showText("无");
	    	            	            }}
	    	            	if(school[1]==92.5541f){
	    	            		if(null!=zy&&zy.size()!=0){
    			    	            //设置字体和大小  
    				    	        over.setFontAndSize(font.getBaseFont(), 8);
    				    	        //设置字体颜色
    				    	        over.setColorFill(BaseColor.RED);
    				    	        over.showText("√");
    				    	        
    	            	            
    	            	            
    	            	            }
	    	            	}
	    	            	
	    	            	
	    	            	if(school[0]==388.5725f){
	            	            if(null!=zy&&zy.size()!=0){
			    	            //设置字体和大小  
				    	        over.setFontAndSize(font.getBaseFont(), 8);
				    	        //设置字体颜色
				    	        over.setColorFill(BaseColor.RED);
				    	        double money =zy.get(2);  
			    	            BigDecimal numberOfMoney = new BigDecimal(money);  
			    	            String s = WxInvoiceHandler.number2CNMontrayUnit(numberOfMoney); 
				    	        over.showText(s);}
	            	            else{
	            	            	over.setFontAndSize(font.getBaseFont(), 8);
					    	        //设置字体颜色
					    	        over.setColorFill(BaseColor.RED);
		    	            	   over.showText("无");
	            	            }
	            	            
	    	            	}
	    	            	
	    	            	
	    	            	
	    	            	if(school[0]==304.8545f){
	            	            if(null!=jzz&&jzz.size()!=0){
			    	            //设置字体和大小  
				    	        over.setFontAndSize(font.getBaseFont(), 8);
				    	        //设置字体颜色
				    	        over.setColorFill(BaseColor.RED);
				    	        over.showText(jzz.get(1).toString());}
	            	            else{
	            	            	over.setFontAndSize(font.getBaseFont(), 8);
					    	        //设置字体颜色
					    	        over.setColorFill(BaseColor.RED);
		    	            	   over.showText("无");
	            	            }}
	    	            	if(school[1]==754.591f){
	            	            if(null!=jzz&&jzz.size()!=0){
	            	            	//设置字体和大小  
    				    	        over.setFontAndSize(font.getBaseFont(), 8);
    				    	        //设置字体颜色
    				    	        over.setColorFill(BaseColor.RED);
    				    	        over.showText("√");
    				    	        }
	            	            }
	            	
	            	      if(school[0]==398.78796f){
        	            if(null!=jzz&&jzz.size()!=0){
	    	            //设置字体和大小  
		    	        over.setFontAndSize(font.getBaseFont(), 8);
		    	        //设置字体颜色
		    	        over.setColorFill(BaseColor.RED);
		    	        double money =jzz.get(1);  
	    	            BigDecimal numberOfMoney = new BigDecimal(money);  
	    	            String s = WxInvoiceHandler.number2CNMontrayUnit(numberOfMoney); 
		    	        over.showText(s);
		    	        
        	            }
        	            else{
        	            	over.setFontAndSize(font.getBaseFont(), 8);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.RED);
    	            	   over.showText("无");
        	            }
        	            
	            	      }
	            	      
	            	      
	            	      if(school[0]==306.057f){
	            	            if(null!=bzz&&bzz.size()!=0){
			    	            //设置字体和大小  
				    	        over.setFontAndSize(font.getBaseFont(), 8);
				    	        //设置字体颜色
				    	        over.setColorFill(BaseColor.RED);
				    	        over.showText(bzz.get(4).toString());}
	            	            else{
	            	            	over.setFontAndSize(font.getBaseFont(), 8);
					    	        //设置字体颜色
					    	        over.setColorFill(BaseColor.RED);
		    	            	   over.showText("无");
	            	            }}
	            	
	            	      if(school[0]==400.033f){
      	            if(null!=bzz&&bzz.size()!=0){
	    	            //设置字体和大小  
		    	        over.setFontAndSize(font.getBaseFont(), 8);
		    	        //设置字体颜色
		    	        over.setColorFill(BaseColor.RED);
		    	        double money =bzz.get(4);  
	    	            BigDecimal numberOfMoney = new BigDecimal(money);  
	    	            String s = WxInvoiceHandler.number2CNMontrayUnit(numberOfMoney); 
		    	        over.showText(s);}
      	            else{
      	            	over.setFontAndSize(font.getBaseFont(), 8);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.RED);
  	            	   over.showText("无");
      	            }}
	            	      
	            	      if(school[1]==734.7551f){
	            	            if(null!=bzz&&bzz.size()!=0){
	      	    	            over.setFontAndSize(font.getBaseFont(), 8);
				    	        //设置字体颜色
				    	        over.setColorFill(BaseColor.RED);
				    	        over.showText("√");}
	            	            }
	            	      
	            	      
	            	      
	            	      
	            	      if(school[0]==306.797f){
	            	            if(null!=gat&&gat.size()!=0){
			    	            //设置字体和大小  
				    	        over.setFontAndSize(font.getBaseFont(), 8);
				    	        //设置字体颜色
				    	        over.setColorFill(BaseColor.RED);
				    	        over.showText(gat.get(3).toString());}
	            	            else{
	            	            	over.setFontAndSize(font.getBaseFont(), 8);
					    	        //设置字体颜色
					    	        over.setColorFill(BaseColor.RED);
		    	            	   over.showText("无");
	            	            }}
	            	
	            	      if(school[0]==400.626f){
    	            if(null!=gat&&gat.size()!=0){
	    	            //设置字体和大小  
		    	        over.setFontAndSize(font.getBaseFont(), 8);
		    	        //设置字体颜色
		    	        over.setColorFill(BaseColor.RED);
		    	        double money =gat.get(3);  
	    	            BigDecimal numberOfMoney = new BigDecimal(money);  
	    	            String s = WxInvoiceHandler.number2CNMontrayUnit(numberOfMoney); 
		    	        over.showText(s);}
    	            else{
    	            	over.setFontAndSize(font.getBaseFont(), 8);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.RED);
	            	   over.showText("无");
    	            }}
	            	      
	            	      
	            	      
	            	      if(school[1]==714.7211f){
	          	            if(null!=gat&&gat.size()!=0){
	          	            	 over.setFontAndSize(font.getBaseFont(), 8);
 				    	        //设置字体颜色
 				    	        over.setColorFill(BaseColor.RED);
 				    	        over.showText("√");
 				    	        }
	          	            }
	            	      

	    	            			    /*//设置字体和大小  
					    	            over.setFontAndSize(font.getBaseFont(), 10);
					    	        //设置字体颜色
					    	        over.setColorFill(BaseColor.RED);
					    	          
				    	            over.showText(j.get(2).toString());
	    		    	        
	    		    	            	if(!j.containsKey(1)){
	    		    	            		
	    		    	            		  
	    		    	            		
	    		    	               }		
	    	            		//设置字体和大小  
			    	            over.setFontAndSize(font.getBaseFont(), 10);
			    	           //设置字体颜色
			    	           over.setColorFill(BaseColor.RED);
			    	          
		    	                over.showText(j.get(1).toString());*/
		    	            
	    	               
	    	            	
	    	            	
	    	              
	    	            	/*if(j.containsKey(2)){
		    	            	if(school[0]==272.53754f){
			    	            //设置字体和大小  
				    	        over.setFontAndSize(font.getBaseFont(), 10);
				    	        //设置字体颜色
				    	        over.setColorFill(BaseColor.RED);
				    	          
			    	            over.showText(j.get(2).toString());
			    	            }
		    	               if(school[0]==388.5725f){
			    	            //设置字体和大小  
				    	        over.setFontAndSize(font.getBaseFont(), 8);
				    	        //设置字体颜色
				    	        over.setColorFill(BaseColor.RED);
				    	        double money =j.get(2);  
			    	            BigDecimal numberOfMoney = new BigDecimal(money);  
			    	            String s = WxInvoiceHandler.number2CNMontrayUnit(numberOfMoney);  
			    	            over.showText(s);
			    	            }
		    	               }
		    	            	if(!j.containsKey(2)){
		    	            	   over.setFontAndSize(font.getBaseFont(), 8);
					    	        //设置字体颜色
					    	        over.setColorFill(BaseColor.RED);
		    	            	   over.showText("无此服务");
		    	               }*/
	    	            
	            	      
	            	      //委托日期
	    	            if(school[0]==161.41649f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 11);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
		    				
		    	            over.showText(filehead.substring(2,4));    
		    	            }
	    	            if(school[0]==200.07549f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 11);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
		    				
		    	            over.showText(filehead.substring(4,6));    
		    	            }
	    	            if(school[0]==238.60649f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 11);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
		    				
		    	            over.showText(filehead.substring(6,8));    
		    	            }
	    	            if(school[0]==389.4865f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 11);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
		    				
		    	            over.showText(filehead.substring(2,4));    
		    	            }
	    	            if(school[0]==428.02502f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 11);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
		    				
		    	            over.showText(filehead.substring(4,6));    
		    	            }
	    	            if(school[0]==461.17798f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 11);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
		    				
		    	            over.showText(filehead.substring(6,8));    
		    	            }
	    	            
	    	            if(school[0]==183.81349f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 11);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
		    				
		    	            over.showText(wgame);    
		    	            }
	    	            
	    	            if(school[0]==441.2245f){
		    	            //设置字体和大小  
			    	        over.setFontAndSize(font.getBaseFont(), 11);
			    	        //设置字体颜色
			    	        over.setColorFill(BaseColor.BLACK);
			    	        if(null!=degree){
			    	        	over.showText(parentName);  
			    	            }else{
			    	            over.showText("");}
		    	                
		    	            }
	    	            
	    	            over.endText();
	    	            
	        			}
	        		}
	        	if(i==7){
	            	//创建一个image对象.
	            	PdfContentByte over1 = stamper.getUnderContent(i);
	                Image image = Image.getInstance(TPLDIR+"yztx.gif");
	                image.setAbsolutePosition(150.41649f, 524.554f);
	                image.scalePercent(14.2f);
	                over1.addImage(image);
	            }
	            if(i==1){
	            	PdfContentByte over3 = stamper.getUnderContent(i);
	                Image image = Image.getInstance(TPLDIR+"Fw.png");
	                image.setAbsolutePosition(152.6454f-8.5f-51.29545455f, 728.76f-23.295f-16.7f-11.5f-7.886363636f);
	                image.scalePercent(35.3f);
	                over3.addImage(image);
        			QRCodeCreate("http://m.51sdx.com/sdx/invoice/checkinvioce.jspx?invoice_no="+filehead, TPLDIR+TPLDIR1+phone+"qrcode.jpg", 15, TPLDIR+"logo.png");
        			PdfContentByte over2 = stamper.getOverContent(i);
	                Image image1 = Image.getInstance(TPLDIR+TPLDIR1+phone+"qrcode.jpg");
	                image1.setAbsolutePosition(152.6454f-8.5f+7.03f, 728.76f-23.295f-8.2f+3.693181818f+2.8f-7.886363636f);
	                image1.scalePercent(31.8f);
	                over2.addImage(image1);
        			
	            }
	        	
	        	
	        }
	         	
	        stamper.close();	
	       
		

	}
	/** 生成qr pdf
	 * 
	 * @param
	 * @param
	 * @param
	 * @param
	 * @return
	 * @throws IOException 
	 * @throws DocumentException */

	
	public  void getQrPdf(String filehead ) throws IOException, DocumentException {
		
		 
		   //创建一个pdf读入流 
		 PdfReader reader = new PdfReader(TPLDIR+"24Gp48.5x47-600.pdf");//24G-48.5x47  24Gp48.5x47 24Gp48.5x47-100 24Gp48.5x47-600
		//根据一个pdfreader创建一个pdfStamper.用来生成新的pdf.  

				PdfStamper stamper = new PdfStamper(reader,
				  new FileOutputStream(TPLDIR+TPLDIR1+filehead+".pdf"));
			
	        //这个字体是itext-asian.jar中自带的 所以不用考虑操作系统环境问题.  
		    BaseFont bfChinese = BaseFont.createFont("C:/WINDOWS/Fonts/SIMYOU.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
			//BaseFont bfChinese = BaseFont.createFont(TPLDIR+"MSYH.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
				
				/*com.itextpdf.text.Font FontChinese24 = new com.itextpdf.text.Font(
						bfChinese, 24, com.itextpdf.text.Font.BOLD);
				com.itextpdf.text.Font FontChinese18 = new com.itextpdf.text.Font(
						bfChinese, 18, com.itextpdf.text.Font.BOLD);
				com.itextpdf.text.Font FontChinese16 = new com.itextpdf.text.Font(
						bfChinese, 16, com.itextpdf.text.Font.BOLD);
				com.itextpdf.text.Font FontChinese12 = new com.itextpdf.text.Font(
						bfChinese, 12, com.itextpdf.text.Font.NORMAL);
				com.itextpdf.text.Font FontChinese11Bold = new com.itextpdf.text.Font(
						bfChinese, 11, com.itextpdf.text.Font.BOLD);
				com.itextpdf.text.Font FontChinese11 = new com.itextpdf.text.Font(
						bfChinese, 11, com.itextpdf.text.Font.ITALIC);
				com.itextpdf.text.Font FontChinese11Normal = new com.itextpdf.text.Font(
						bfChinese, 11, com.itextpdf.text.Font.NORMAL);*/  
	        //baseFont不支持字体样式设定.但是font字体要求操作系统支持此字体会带来移植问题.  
	        Font font = new Font(bfChinese,10);
	        font.setStyle(Font.BOLD);
	        font.getBaseFont(); 
	        
	        List<float[]> arrays = new ArrayList<float[]>();
	        float[] p1 = {528.1806452f, 728.76f, 1.0f}; 
	        float[] p2 = {229.098f, 166.989f, 1.0f};
	        float[] p3 = {297.859f, 166.989f, 1.0f};
	        float[] p4 = {360.267f, 166.989f, 1.0f};
	        float[] p5 = {261.17047f, 660.522f, 2.0f};
	        float[] p6 = {126.7125f, 636.803f, 2.0f};
	        float[] p7 = {329.5305809f, 636.193f, 2.0f};
	        float[] p8 = {272.53754f, 92.554f, 2.0f};
	        float[] p9 = {388.5725f, 92.554f, 2.0f};
	        float[] p10 = {161.833f, 613.57f, 2.0f};
	        float[] p11 = {161.833f, 590.027f, 2.0f};
	        float[] p12 = {161.833f, 566.857f, 2.0f};
	        float[] p13 = {161.833f, 542.567f, 2.0f};
	        float[] p14 = {337.471f, 496.228f, 2.0f};
	        float[] p15 = {161.833f, 473.059f, 2.0f};
	        float[] p16 = {161.833f, 449.142f, 2.0f};
	        float[] p17 = {161.833f, 425.225f, 2.0f};
	        float[] p18 = {161.833f, 403.925f, 2.0f};
	        float[] p19 = {304.8545f, 754.59f, 3.0f};
	        float[] p20 = {398.78796f,754.59f, 3.0f};
	        float[] p21 = {306.057f, 734.495f, 3.0f};
	        float[] p22 = {400.033f, 734.755f, 3.0f};
	        float[] p23 = {306.797f, 714.516f, 3.0f};
	        float[] p24 = {400.626f, 714.721f, 3.0f};
	        

	        
          arrays.add(p1);
          arrays.add(p2);
          arrays.add(p3);
          arrays.add(p4);
          arrays.add(p5);
          arrays.add(p6);
          arrays.add(p7);
          arrays.add(p8);
          arrays.add(p9);
          arrays.add(p10);
          arrays.add(p11);
          arrays.add(p12);
          arrays.add(p13);
          arrays.add(p14);
          arrays.add(p15);
          arrays.add(p16);
          arrays.add(p17);
          arrays.add(p18);
          arrays.add(p19);
          arrays.add(p20);
          arrays.add(p21);
          arrays.add(p22);
          arrays.add(p23);
          arrays.add(p24);
          
	        
	        
	        /*List<float[]> first=getKeyWords(reader,"牛"); //[352.85416, 728.33, 1.0] //385.6, 728.76, 1.0
	        System.out.println(first.toString());;*/
            int num=1;
            long name=0;
	        for (int i=1; i<=reader.getNumberOfPages(); i++){
	        	    
	        	      for (int k=0; k<6; k++){
	        	      for (int j=0; j<4; j++){
	        			 //获得pdfstamper在当前页的上层打印内容.也就是说 这些内容会覆盖在原先的pdf内容之上.  
	    	            PdfContentByte over = stamper.getOverContent(i);
	    	          //用pdfreader获得当前页字典对象.包含了该页的一些数据.比如该页的坐标轴信息.  
	    	            PdfDictionary p = reader.getPageN(i);
	    	          //拿到mediaBox 里面放着该页pdf的大小信息.  
	    	            PdfObject po =  p.get(new PdfName("MediaBox"));
	    	            System.out.println(po.isArray());
	    	          //po是一个数组对象.里面包含了该页pdf的坐标轴范围.  
	    	            PdfArray pa = (PdfArray) po;
	    	            System.out.println(pa.size());
	    	            //看看y轴的最大值.  
	    	            System.out.println(pa.getAsNumber(pa.size()-1));
	    	            //开始写入文本  
	    	            over.beginText();  
	    	            
	    	          //设置字体的输出位置  
	    	            //over.setTextMatrix(school[0]-6.25f, school[1]);
	    	            float x=137.6f;float y=133.5f; 
	    	            over.setTextMatrix(57.00666551f+j*x, 706.2936544f-y*k);
	    	          //要输出的text  
	    	          
	    	            //设置字体和大小  
		    	        over.setFontAndSize(font.getBaseFont(), 10);
		    	        //设置字体颜色
		    	        over.setColorFill(BaseColor.BLACK);
	    				
		    	        name =Long.parseLong(filehead)+num;
	    	            over.showText(name+"");    
	    	            
                        over.endText();
                        
	    	           
	        		
                        /*for (int i = 0; i < num; i++)
            			{
            			String imgPath=TPLDIR1+TPLDIR2+filehead+i+".jpg";
            			File imgFile = new File(imgPath);
            			xInvoiceHandler.QRCodeCreate("http://m.51sdx.com/sdx/invoice/checkinvioce.jspx?invoice_no="+filehead, imgPath, 15, TPLDIR1+"logo.png");
            		    BufferedImage out= xInvoiceHandler.coverImage(TPLDIR1+"Fw.png", imgPath, 157, 78, 241, 206);
            		    String imgType = imgPath.substring(imgPath.lastIndexOf(".") + 1, imgPath.length());
            		    ImageIO.write(out, imgType, imgFile);
            		    }*/
                        WxInvoiceHandler xInvoiceHandler=new WxInvoiceHandler();
            			String imgPath=TPLDIR+TPLDIR1+name+""+".jpg";
            			//File imgFile = new File(imgPath);
            			xInvoiceHandler.QRCodeCreate("http://m.51sdx.com/sdx/invoice/checkinvioce.jspx?invoice_no="+name+"", imgPath, 15, TPLDIR+"logo.png");
            		    /*BufferedImage out;
						try {
							out = xInvoiceHandler.coverImage(TPLDIR+"Fw.png", imgPath, 157, 78, 241, 206);
							String imgType = imgPath.substring(imgPath.lastIndexOf(".") + 1, imgPath.length());
	            		    ImageIO.write(out, imgType, imgFile);
						}
						catch (Exception e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
            		    */
            		    
	        	      
	            	/*PdfContentByte over3 = stamper.getUnderContent(i);
	                Image image = Image.getInstance(TPLDIR+"Fw.png");
	                image.setAbsolutePosition(152.6454f-8.5f-51.29545455f, 728.76f-23.295f-16.7f-11.5f-7.886363636f);
	                image.scalePercent(35.3f);
	                over3.addImage(image);*/
        			//QRCodeCreate("http://m.51sdx.com/sdx/invoice/checkinvioce.jspx?invoice_no="+filehead, TPLDIR+TPLDIR1+phone+"qrcode.jpg", 15, TPLDIR+"logo.png");
        			PdfContentByte over2 = stamper.getOverContent(i);
	                Image image1 = Image.getInstance(TPLDIR+TPLDIR1+name+""+".jpg");
	                image1.scalePercent(38.53f);
	                image1.setAbsolutePosition(46.04083234f+j*x, 721.1819919f-y*k);
	                over2.addImage(image1);
	                num++;
	            }
	        	
	        	
	        }
	         	
	        	
	       }
	        stamper.close(); 
	       }
	/**
   * 返回关键字所在页码和坐标
   * @param
   * @param
   * @return  List<float[]>  返回关键字所在的坐标和页数 float[0] >> X; float[1] >> Y; float[2] >> page
   */
  public   List<float[]> getKeyWords(PdfReader reader, final String key) {
      final List<float[]> arrays = new ArrayList<float[]>();
      PdfReader pdfReader;
          try {
              int pageNum = reader.getNumberOfPages();
              PdfReaderContentParser pdfReaderContentParser = new PdfReaderContentParser(reader);

              for (int i = 1; i <= pageNum; i++) {

                  final int finalI = i;
                  pdfReaderContentParser.processContent(i, new RenderListener() {
                      //此方法是监听PDF里的文字内容，有重复情况会都把坐标和页码信息都存入arrays里
                      @Override
                      public void renderText(TextRenderInfo textRenderInfo) {
                          String text = textRenderInfo.getText(); // 整页内容

                          if (null != text && text.contains(key)) {
                              Rectangle2D.Float boundingRectange = textRenderInfo
                                      .getBaseline().getBoundingRectange();
                              float[] resu = new float[3];
                              resu[0] = (float)boundingRectange.getCenterX();
                              resu[1] = (float)boundingRectange.getCenterY();
                              resu[2] = finalI;
                              arrays.add(resu);
                          }
                      }

                      //此方法是监听PDF里的图片内容
                      @Override
                      public void renderImage(ImageRenderInfo arg0) {/*
                          PdfImageObject image0;
                          try {
                              image0 = arg0.getImage();
                              byte[] imageByte = image0.getImageAsBytes();
                              Image imageInPDF = Image.getInstance(imageByte);
                              if(image0!=null && imageInPDF.equals(image)){
                                  float[] resu = new float[3];
                                  // 0 => x;  1 => y;  2 => z
                                  //z的值始终为1
                                  resu[0] = arg0.getStartPoint().get(0);
                                  resu[1] = arg0.getStartPoint().get(1);
                                  resu[2] = finalI;
                                  arrays.add(resu);
                              }
                          } catch (IOException e) {
                              e.printStackTrace();
                          } catch (BadElementException e) {
                              e.printStackTrace();
                          }

                      */}

                      @Override
                      public void endTextBlock() {


                      }

                      @Override
                      public void beginTextBlock() {


                      }

                  });

              }

             

          } catch (IOException e) {

              e.printStackTrace();
          }
          return arrays;
  }
  /** 
   * <span style="font-size:18px;font-weight:blod;">QRCode 方式生成二维码</span> 
   * @param content    二维码内容 
   * @param imgPath    二维码生成路径 
   * @param version    二维码版本 
   * @param
   */  
  public static void QRCodeCreate(String content, String imgPath, int version, String logoPath){  
       try {    
          Qrcode qrcodeHandler = new Qrcode();    
          //设置二维码排错率，可选L(7%) M(15%) Q(25%) H(30%)，排错率越高可存储的信息越少，但对二维码清晰度的要求越小      
          qrcodeHandler.setQrcodeErrorCorrect('Q');    
          //N代表数字,A代表字符a-Z,B代表其他字符    
          qrcodeHandler.setQrcodeEncodeMode('B');    
          //版本1为21*21矩阵，版本每增1，二维码的两个边长都增4；所以版本7为45*45的矩阵；最高版本为是40，是177*177的矩阵    
          qrcodeHandler.setQrcodeVersion(version);  
          //根据版本计算尺寸  
          int imgSize = 67 + 12 * (version - 1) ;    
          byte[] contentBytes = content.getBytes("gb2312");    
          BufferedImage bufImg = new BufferedImage(imgSize , imgSize ,BufferedImage.TYPE_INT_RGB);    
          Graphics2D gs = bufImg.createGraphics();    
          gs.setBackground(Color.WHITE);    
          gs.clearRect(0, 0, imgSize , imgSize);    
          // 设定图像颜色 > BLACK  
          gs.setColor(Color.BLACK);  
          // 设置偏移量 不设置可能导致解析出错    
          int pixoff = 2;  
          // 输出内容 > 二维码    
          if (contentBytes.length > 0 && contentBytes.length < 130) {  
              boolean[][] codeOut = qrcodeHandler.calQrcode(contentBytes);  
              for (int i = 0; i < codeOut.length; i++) {  
                  for (int j = 0; j < codeOut.length; j++) {  
                      if (codeOut[j][i]) {    
                          gs.fillRect(j * 3 + pixoff, i * 3 + pixoff, 3, 3);  
                      }    
                  }    
              }    
          } else {    
              System.err.println("QRCode content bytes length = " + contentBytes.length + " not in [ 0,130 ]. ");    
          }  
         /* 判断是否需要添加logo图片 */  
          if(logoPath != null){  
              File icon = new File(logoPath);  
              if(icon.exists()){  
                  int width_4 = imgSize / 4;  
                  int width_8 = width_4 / 2;  
                  int height_4 = imgSize / 4;  
                  int height_8 = height_4 / 2;  
                  BufferedImage img = ImageIO.read(icon);  
                  gs.drawImage(img, width_4 + width_8, height_4 + height_8,width_4,height_4, null);  
                  gs.dispose();  
                  bufImg.flush();  
              }else{  
                  System.out.println("Error: login图片还在在！");  
              }  

          }  


          gs.dispose();  
          bufImg.flush();  
          //创建二维码文件  
          File imgFile = new File(imgPath);  
          if(!imgFile.exists())  
              imgFile.createNewFile();  
          //根据生成图片获取图片  
          String imgType = imgPath.substring(imgPath.lastIndexOf(".") + 1, imgPath.length());  
          // 生成二维码QRCode图片    
          ImageIO.write(bufImg, imgType, imgFile);    
       } catch (Exception e) {    
           e.printStackTrace();    
       }  
  }  
  /**
   * 图片覆盖（覆盖图压缩到width*height大小，覆盖到底图上）
   *
   * @param baseBufferedImage 底图
   * @param coverBufferedImage 覆盖图
   * @param x 起始x轴
   * @param y 起始y轴
   * @param width 覆盖宽度
   * @param height 覆盖长度度
   * @return
   * @throws Exception
   */
  public static BufferedImage coverImage(BufferedImage baseBufferedImage, BufferedImage coverBufferedImage, int x, int y, int width, int height) throws Exception{
       
      // 创建Graphics2D对象，用在底图对象上绘图
      Graphics2D g2d = baseBufferedImage.createGraphics();
       
      // 绘制
      g2d.drawImage(coverBufferedImage, x, y, width, height, null);
      g2d.dispose();// 释放图形上下文使用的系统资源
       
      return baseBufferedImage;
  }
  /**
   * 图片覆盖（覆盖图压缩到width*height大小，覆盖到底图上）
   *
   * @param baseFilePath 底图
   * @param coverFilePath 覆盖图
   * @param x 起始x轴
   * @param y 起始y轴
   * @param width 覆盖宽度
   * @param height 覆盖长度度
   * @return
   * @throws Exception
   */
  public static BufferedImage coverImage(String baseFilePath, String coverFilePath, int x, int y, int width, int height) throws Exception{
	  /*ImageIcon src = new ImageIcon(file.getAbsolutePath());
      BufferedImage bufferedImage = new BufferedImage(src.getIconWidth(),
              src.getIconHeight(), BufferedImage.TYPE_INT_RGB);
      Graphics g = bufferedImage.createGraphics();
      g.setColor(Color.white);
      g.fillRect(0, 0, src.getIconWidth(), src.getIconHeight());
      g.drawImage(src.getImage(), 0, 0, null);
      g.dispose();
      
      */
	  ImageIcon src = new ImageIcon(baseFilePath);
	  BufferedImage bufferedImage = new BufferedImage(src.getIconWidth(),
              src.getIconHeight(), BufferedImage.TYPE_INT_RGB);
      Graphics g = bufferedImage.createGraphics();
      g.setColor(Color.white);
      g.fillRect(0, 0, src.getIconWidth(), src.getIconHeight());
      g.drawImage(src.getImage(), 0, 0, null);
      g.dispose();
      
      ImageIcon src1 = new ImageIcon(coverFilePath);
	  BufferedImage coverImg = new BufferedImage(src1.getIconWidth(),
			  src1.getIconHeight(), BufferedImage.TYPE_INT_RGB);
      Graphics g1 = coverImg.createGraphics();
      g1.setColor(Color.white);
      g1.fillRect(0, 0, src1.getIconWidth(), src1.getIconHeight());
      g1.drawImage(src1.getImage(), 0, 0, null);
      g1.dispose();
       
     
       
      bufferedImage = coverImage(bufferedImage, coverImg, x, y, width, height);
     
      
      /* File baseFile = new File(baseFilePath);//底图
      BufferedImage buffImg = ImageIO.read(baseFile);
      
       
      File coverFile = new File(coverFilePath); //覆盖层
      BufferedImage coverImg = ImageIO.read(coverFile);
       
      buffImg = coverImage(buffImg, coverImg, x, y, width, height);*/
       
      return bufferedImage;
  }
}  




